import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Card, Form } from 'antd';
import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
import CurrentComponent from './Step1';

@Form.create()
class StepForm extends PureComponent {
  componentDidMount() {
    console.log('fetchall');
    this.props.dispatch({
      type: 'paper/fetchall',
      payload: {
        pageSize: 100,
      },
    });
  }
  render() {
    const { form, stepFormData, submitting, dispatch, paper: { fulllist } } = this.props;
    const formItemLayout = {
      labelCol: {
        span: 3,
      },
      wrapperCol: {
        span: 21,
      },
    };
    return (
      <PageHeaderLayout title="新增考试" content="分布完成考试配置，确保人数都能够安排到考场中">
        <Card bordered={false}>
          <div>
            <CurrentComponent
              formItemLayout={formItemLayout}
              form={form}
              dispatch={dispatch}
              data={stepFormData}
              submitting={submitting}
              paperList={fulllist || []} />
          </div>
        </Card>
      </PageHeaderLayout>
    );
  }
}

export default connect(state => ({
  stepFormData: state.exam.step,
  submitting: state.exam.stepFormSubmitting,
  paper: state.paper,
}))(StepForm);
